package com.misalen.test;

import java.util.Date;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.misalen.web.database.model.mysql.sys.SysWordbook;
import org.misalen.web.database.model.mysql.sys.SysWordbookItem;
import org.misalen.web.server.controllers.BaseController;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring/applicationContext.xml", "classpath:spring/spring-servlet.xml" })
public class 字典表数据 extends BaseController {
	SysWordbook sysWordbook;
	String[] proage;
	@Test
	public void Test() {
		sysWordbookItemRepository.delete(SysWordbookItem.class, null);
		sysWordbookRepository.delete(SysWordbook.class, null);

		sysWordbook = new SysWordbook();
		sysWordbook.setAddTime(new Date());
		sysWordbook.setWordbookCode("pro-client-type");
		sysWordbook.setWordbookName("终端类型");
		sysWordbookRepository.save(sysWordbook);
		proage = new String[] {"android司机端", "android用户端", "iOS司机端","iOS用户端","车载终端" };
		for (String string : proage) {
			SysWordbookItem sysWordbookItem = new SysWordbookItem();
			sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
			sysWordbookItem.setAddTime(new Date());
			if (string.equals("android司机端")) {
				sysWordbookItem.setItemCode("androidDriver");
			}else if (string.equals("android用户端")) {
				sysWordbookItem.setItemCode("androidUser");
			}else if (string.equals("iOS司机端")) {
				sysWordbookItem.setItemCode("iOSDriver");
			}else if (string.equals("iOS用户端")) {
				sysWordbookItem.setItemCode("iOSUser");
			} else {
				sysWordbookItem.setItemCode("machine");
			}
			sysWordbookItem.setItemName(string);
			sysWordbookItemRepository.save(sysWordbookItem);
		}
		
		
		sysWordbook = new SysWordbook();
		sysWordbook.setAddTime(new Date());
		sysWordbook.setWordbookCode("pro-advertising-state");
		sysWordbook.setWordbookName("广告状态");
		sysWordbookRepository.save(sysWordbook);
		proage = new String[] {"未支付", "审核中", "正在推广" };
		for (String string : proage) {
			SysWordbookItem sysWordbookItem = new SysWordbookItem();
			sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
			sysWordbookItem.setAddTime(new Date());
			if (string.equals("未支付")) {
				sysWordbookItem.setItemCode("noPay");
			}else if (string.equals("审核中")) {
				sysWordbookItem.setItemCode("underReview");
			} else {
				sysWordbookItem.setItemCode("generalize");
			}
			sysWordbookItem.setItemName(string);
			sysWordbookItemRepository.save(sysWordbookItem);
		}
		sysWordbook = new SysWordbook();
		sysWordbook.setAddTime(new Date());
		sysWordbook.setWordbookCode("pro-extract-type");
		sysWordbook.setWordbookName("提现类型");
		sysWordbookRepository.save(sysWordbook);
		proage = new String[] { "支付宝", "微信" };
		for (String string : proage) {
			SysWordbookItem sysWordbookItem = new SysWordbookItem();
			sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
			sysWordbookItem.setAddTime(new Date());
			if (string.equals("支付宝")) {
				sysWordbookItem.setItemCode("alipay");
			} else {
				sysWordbookItem.setItemCode("wechat");
			}
			sysWordbookItem.setItemName(string);
			sysWordbookItemRepository.save(sysWordbookItem);
		}
		sysWordbook = new SysWordbook();
		sysWordbook.setAddTime(new Date());
		sysWordbook.setWordbookCode("pro-extract-state");
		sysWordbook.setWordbookName("提现状态");
		sysWordbookRepository.save(sysWordbook);
		proage = new String[] { "未操作", "完成", "拒绝" };
		for (String string : proage) {
			SysWordbookItem sysWordbookItem = new SysWordbookItem();
			sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
			sysWordbookItem.setAddTime(new Date());
			if (string.equals("未操作")) {
				sysWordbookItem.setItemCode("not-operating");
			} else if (string.equals("完成")) {
				sysWordbookItem.setItemCode("complete");
			} else {
				sysWordbookItem.setItemCode("refuse");
			}
			sysWordbookItem.setItemName(string);
			sysWordbookItemRepository.save(sysWordbookItem);
		}
		sysWordbook = new SysWordbook();
		sysWordbook.setAddTime(new Date());
		sysWordbook.setWordbookCode("pro-video-advertising-type");
		sysWordbook.setWordbookName("视频广告类型");
		sysWordbookRepository.save(sysWordbook);
		proage = new String[] { "头枕广告", "后座广告" };
		for (String string : proage) {
			SysWordbookItem sysWordbookItem = new SysWordbookItem();
			sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
			sysWordbookItem.setAddTime(new Date());
			if (string.equals("头枕广告")) {
				sysWordbookItem.setItemCode("headrest");
			} else {
				sysWordbookItem.setItemCode("backseat");
			}
			sysWordbookItem.setItemName(string);
			sysWordbookItemRepository.save(sysWordbookItem);
		}

		sysWordbook = new SysWordbook();
		sysWordbook.setAddTime(new Date());
		sysWordbook.setWordbookCode("pro-promotion-model");
		sysWordbook.setWordbookName("推广模式");
		sysWordbookRepository.save(sysWordbook);
		proage = new String[] { "区域推广", "附近推广" };
		for (String string : proage) {
			SysWordbookItem sysWordbookItem = new SysWordbookItem();
			sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
			sysWordbookItem.setAddTime(new Date());
			if (string.equals("区域推广")) {
				sysWordbookItem.setItemCode("area");
			} else {
				sysWordbookItem.setItemCode("near");
			}
			sysWordbookItem.setItemName(string);
			sysWordbookItemRepository.save(sysWordbookItem);
		}

		sysWordbook = new SysWordbook();
		sysWordbook.setAddTime(new Date());
		sysWordbook.setWordbookCode("pro-video-state");
		sysWordbook.setWordbookName("视频发布状态");
		sysWordbookRepository.save(sysWordbook);
		proage = new String[] { "发布中", "禁用中" };
		for (String string : proage) {
			SysWordbookItem sysWordbookItem = new SysWordbookItem();
			sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
			sysWordbookItem.setAddTime(new Date());
			if (string.equals("发布中")) {
				sysWordbookItem.setItemCode("release");
			} else {
				sysWordbookItem.setItemCode("disable");
			}
			sysWordbookItem.setItemName(string);
			sysWordbookItemRepository.save(sysWordbookItem);
		}

		sysWordbook = new SysWordbook();
		sysWordbook.setAddTime(new Date());
		sysWordbook.setWordbookCode("sys-carrier-type");
		sysWordbook.setWordbookName("广告载体类型");
		sysWordbookRepository.save(sysWordbook);
		proage = new String[] { "热文", "新闻", "娱乐", "财经" };
		for (String string : proage) {
			SysWordbookItem sysWordbookItem = new SysWordbookItem();
			sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
			sysWordbookItem.setAddTime(new Date());
			sysWordbookItem.setItemCode(string);
			sysWordbookItem.setItemName(string);
			sysWordbookItemRepository.save(sysWordbookItem);
		}

		sysWordbook = new SysWordbook();
		sysWordbook.setAddTime(new Date());
		sysWordbook.setWordbookCode("pro-social-groups");
		sysWordbook.setWordbookName("社会群体");
		sysWordbookRepository.save(sysWordbook);
		proage = new String[] { "司机", "学生", "白领", "无业", "其他" };
		for (String string : proage) {
			SysWordbookItem sysWordbookItem = new SysWordbookItem();
			sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
			sysWordbookItem.setAddTime(new Date());
			sysWordbookItem.setItemName(string);
			sysWordbookItem.setItemCode(string);
			sysWordbookItemRepository.save(sysWordbookItem);
		}

		sysWordbook = new SysWordbook();
		sysWordbook.setAddTime(new Date());
		sysWordbook.setWordbookCode("pro-age");
		sysWordbook.setWordbookName("年龄范围");
		sysWordbookRepository.save(sysWordbook);
		proage = new String[] { "0-20", "20-30", "30-40", "40-50", "50-99" };
		for (String string : proage) {
			SysWordbookItem sysWordbookItem = new SysWordbookItem();
			sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
			sysWordbookItem.setAddTime(new Date());
			sysWordbookItem.setItemName(string);
			sysWordbookItem.setItemCode(string);
			sysWordbookItemRepository.save(sysWordbookItem);
		}

		sysWordbook = new SysWordbook();
		sysWordbook.setAddTime(new Date());
		sysWordbook.setWordbookCode("pro-city");
		sysWordbook.setWordbookName("归属城市");
		sysWordbookRepository.save(sysWordbook);
		SysWordbookItem sysWordbookItem = new SysWordbookItem();
		sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
		sysWordbookItem.setAddTime(new Date());
		sysWordbookItem.setItemName("兰州");
		sysWordbookItem.setItemCode("兰州");
		sysWordbookItemRepository.save(sysWordbookItem);
		sysWordbookItem = new SysWordbookItem();
		sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
		sysWordbookItem.setAddTime(new Date());
		sysWordbookItem.setItemName("上海");
		sysWordbookItem.setItemCode("上海");
		sysWordbookItemRepository.save(sysWordbookItem);
		sysWordbookItem = new SysWordbookItem();
		sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
		sysWordbookItem.setAddTime(new Date());
		sysWordbookItem.setItemName("全国");
		sysWordbookItem.setItemCode("全国");
		sysWordbookItemRepository.save(sysWordbookItem);

		sysWordbook = new SysWordbook();
		sysWordbook.setAddTime(new Date());
		sysWordbook.setWordbookCode("pro-sms-type");
		sysWordbook.setWordbookName("短信发送类型");
		sysWordbookRepository.save(sysWordbook);
		sysWordbookItem = new SysWordbookItem();
		sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
		sysWordbookItem.setAddTime(new Date());
		sysWordbookItem.setItemName("找回密码");
		sysWordbookItem.setItemCode("find-pwd");
		sysWordbookItemRepository.save(sysWordbookItem);
		sysWordbookItem = new SysWordbookItem();
		sysWordbookItem.setWordbookId(sysWordbook.getPrimaryKey());
		sysWordbookItem.setAddTime(new Date());
		sysWordbookItem.setItemName("注册");
		sysWordbookItem.setItemCode("registered");
		sysWordbookItemRepository.save(sysWordbookItem);
	}
}
